//
//  ZHStatisticsColumnarCollectionViewCell.m
//  Doctor
//
//  Created by liuzhishan on 15/12/17.
//  Copyright © 2015年 shanshan. All rights reserved.
//

#import "ZHStatisticsColumnarCollectionViewCell.h"
#import "ZHClinicAllData.h"
#import "DataTool.h"
#define ALLHEIGHT 250
@interface ZHStatisticsColumnarCollectionViewCell ()

@property (nonatomic,retain) UILabel *lableDate;

@property (nonatomic,retain) UIView *downLeftView;
@property (nonatomic,retain) UIView *centerLeftView;
@property (nonatomic,retain) UIView *upLeftView;

@property (nonatomic,retain) UIView *downRighttView;
@property (nonatomic,retain) UIView *centerRightView;
@property (nonatomic,retain) UIView *upRightView;

@end

@implementation ZHStatisticsColumnarCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addMYCollectionChildViews];
    }
    return self;
}

-(void)addMYCollectionChildViews
{
   // self.contentView.backgroundColor = BGDEEPCOLOR;
    
    
    UIImageView *bgImageView = [[UIImageView alloc]init];
    [bgImageView setMyFramewithX:0 andY:0 andWidth:78 andHeight:250];
    bgImageView.image = [UIImage imageNamed:@"clinic-form"];
    [self.contentView addSubview:bgImageView];
    
    
    self.lableDate = [[UILabel alloc]init];
    [self.lableDate setMyFramewithX:30 andY:250 andWidth:48 andHeight:20];
    [self.contentView addSubview:self.lableDate];
    self.lableDate.textAlignment = NSTextAlignmentRight;
    self.lableDate.font = [UIFont systemFontOfSize:13 * WIDPro -2];
    
    
    
    self.upLeftView  = [[UIView alloc]init];
    self.upLeftView.backgroundColor = ORANGECOLOR;
    [self.upLeftView setMyFramewithX:0 andY:10 andWidth:10 andHeight:0];
    [self.contentView addSubview:self.upLeftView];
    
    self.upRightView  = [[UIView alloc]init];
    self.upRightView.backgroundColor = ORANGECOLOR;
    [self.upRightView setMyFramewithX:68 andY:0 andWidth:10 andHeight:0];
    [self.contentView addSubview:self.upRightView];
    
    
    self.centerLeftView  = [[UIView alloc]init];
    self.centerLeftView.backgroundColor = PINKCOLOR;
    [self.centerLeftView setMyFramewithX:0 andY:40 andWidth:10 andHeight:0];
    [self.contentView addSubview:self.centerLeftView];
    
    self.centerRightView  = [[UIView alloc]init];
    self.centerRightView.backgroundColor = PINKCOLOR;
    [self.centerRightView setMyFramewithX:68 andY:40 andWidth:10 andHeight:0];
    [self.contentView addSubview:self.centerRightView];
    
    
    
    
    self.downLeftView  = [[UIView alloc]init];
    self.downLeftView.backgroundColor = BLUECOLOR;
    [self.downLeftView setMyFramewithX:0 andY:80 andWidth:10 andHeight:0];
    [self.contentView addSubview:self.downLeftView];
    
    self.downRighttView  = [[UIView alloc]init];
    self.downRighttView.backgroundColor = BLUECOLOR;
    [self.downRighttView setMyFramewithX:68 andY:80 andWidth:10 andHeight:0];
    [self.contentView addSubview:self.downRighttView];
    
    
    
    
    
    
}
-(void)setDataWithArray:(NSMutableArray *)array andIndex:(NSInteger)index
{
    

    
    if (index == array.count)
    {
        
        ZHClinicAllData *beforeModel = array [index - 1];
        
        
        CGFloat beforeOrangeHeight = beforeModel.orangeProportion * ALLHEIGHT;
        CGFloat beforePinkHeight = beforeModel.pinkProportion * ALLHEIGHT;
        CGFloat beforeBlueHeight = beforeModel.blueProportion * ALLHEIGHT;
        
        //nslog(@"ooooo%f",beforeOrangeHeight + beforePinkHeight + beforeBlueHeight);
        
        self.upLeftView.height = beforeOrangeHeight * HEIPro;
        self.centerLeftView.height = beforePinkHeight * HEIPro ;
        self.downLeftView.height =  beforeBlueHeight * HEIPro;
        
        self.downLeftView.y = (ALLHEIGHT - beforeBlueHeight)*HEIPro;
        self.centerLeftView.y = (ALLHEIGHT - beforeBlueHeight - beforePinkHeight ) * HEIPro;
        self.upLeftView.y = (ALLHEIGHT - beforeBlueHeight - beforePinkHeight - beforeOrangeHeight) * HEIPro;
        

        
        self.upRightView.height = 0;
        self.centerRightView.height = 0 ;
        self.downRighttView.height = 0;
        
        self.lableDate.text = @"";
        return;
    }
    
    ZHClinicAllData *model = array[index];
    
    self.lableDate.text = [NSString stringWithFormat:@"%@",[DataTool removeDateYear:model.dateTime]];
    
    CGFloat orangeHeight = model.orangeProportion * ALLHEIGHT;
    CGFloat pinkHeight = model.pinkProportion * ALLHEIGHT;
    CGFloat blueHeight = model.blueProportion * ALLHEIGHT;
    
    self.upRightView.height = orangeHeight * HEIPro;
    self.centerRightView.height = pinkHeight * HEIPro;
    self.downRighttView.height = blueHeight * HEIPro;
    
    self.downRighttView.y = (ALLHEIGHT - blueHeight)*HEIPro;
    self.centerRightView.y = (ALLHEIGHT - pinkHeight - blueHeight ) * HEIPro;
    self.upRightView.y = (ALLHEIGHT - pinkHeight - blueHeight - orangeHeight) * HEIPro;
    
    
  //  //nslog(@"%f  %f   %f ",self.upRightView.y, self.centerRightView.y )
    
    
    if (index == 0) {
        
        self.upLeftView.height = 0;
        self.centerLeftView.height = 0 ;
        self.downLeftView.height = 0;
        
        return;
    }
    
    
    ZHClinicAllData *beforeModel = array [index - 1];
    
    
    CGFloat beforeOrangeHeight = beforeModel.orangeProportion * ALLHEIGHT;
    CGFloat beforePinkHeight = beforeModel.pinkProportion * ALLHEIGHT;
    CGFloat beforeBlueHeight = beforeModel.blueProportion * ALLHEIGHT;
    
    //nslog(@"ooooo%f",beforeOrangeHeight + beforePinkHeight + beforeBlueHeight);
    
    self.upLeftView.height = beforeOrangeHeight * HEIPro;
    self.centerLeftView.height = beforePinkHeight * HEIPro ;
    self.downLeftView.height =  beforeBlueHeight * HEIPro;
    
    self.downLeftView.y = (ALLHEIGHT - beforeBlueHeight)*HEIPro;
    self.centerLeftView.y = (ALLHEIGHT - beforeBlueHeight - beforePinkHeight ) * HEIPro;
    self.upLeftView.y = (ALLHEIGHT - beforeBlueHeight - beforePinkHeight - beforeOrangeHeight) * HEIPro;


    
    
}




@end
